package com.buba.record.controller;


import com.buba.pojo.record.BloodRoutineExaminatio;
import com.buba.pojo.record.Convention;
import com.buba.record.service.BloodRoutineExaminatioService;
import com.buba.record.service.impl.ConventionServiceImpl;
import com.buba.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * <p>
 * 血常规检查表 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-06-09
 */
@RestController
@RequestMapping("/record/blood-routine-examinatio")
public class BloodRoutineExaminatioController {

    @Autowired
    private BloodRoutineExaminatioService bloodRoutineExaminatioService;

    @Autowired
    private ConventionServiceImpl conventionService;

    //血常规添加
//    @PostMapping("/addBloodRoutineExaminatio")
//    private R addBloodRoutineExaminatio(@RequestBody BloodRoutineExaminatio bloodRoutineExaminatio){
//
//        int  i=bloodRoutineExaminatioService.addBloodRoutineExaminatio(bloodRoutineExaminatio);
//        if (i>0){
//            return R.ok().data("ok","添加成功");
//        }else {
//            return R.error().data("error","添加失败");
//        }
//    }

//    //日常检查添加
//    @PostMapping("/addconvention")
//    private R addconvention(@RequestBody Convention convention){
//
//        int  i=bloodRoutineExaminatioService.addconvention(convention);
//        if (i>0){
//            return R.ok().data("ok","添加成功");
//        }else {
//            return R.error().data("error","添加失败");
//        }
//    }

    //血常规添加
    @PostMapping("/addBloodRoutineExaminatio")
    private R addBloodRoutineExaminatio(@RequestBody BloodRoutineExaminatio bloodRoutineExaminatio){
        bloodRoutineExaminatio.setProjectName("血常规检查");
        bloodRoutineExaminatio.setCreateTime(new Date());
        bloodRoutineExaminatio.setUpdateTime(new Date());
        bloodRoutineExaminatio.setDeleteFlag("0");
        boolean save=bloodRoutineExaminatioService.save(bloodRoutineExaminatio);
        if (save==true){
            return R.ok().data("ok","添加成功");
        }else {
            return R.error().data("error","添加失败");
        }
    }

    //日常检查添加
    @PostMapping("/addconvention")
    private R addconvention(@RequestBody Convention convention){
        convention.setProjectName("常规检查");
        convention.setCreateTime(new Date());
        convention.setUpdateTime(new Date());
        convention.setDeleteFlag("0");
        boolean save = conventionService.save(convention);
        if (save == true){
            return R.ok().data("ok","添加成功");
        }else {
            return R.error().data("error","添加失败");
        }
    }

}

